﻿using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using Microsoft.Practices.Prism.ViewModel;

namespace FU.Capstones.IMS.Web.Common.InventoryServiceProxy.DataContracts
{
    [DataContract(Namespace = WebConstants.ServiceNamespace)]
    public class Warehouse : BindingModelBase<Warehouse>
    {
        public Warehouse()
        {
            AddAllAttributeValidators();
        }
        private int warehouseID;
        [DataMember]
        [Key]
        public int WarehouseID
        {
            get { return warehouseID; }
            set
            {
                if(!Equals(warehouseID,value))
                {
                    warehouseID = value;
                    RaisePropertyChanged(()=>WarehouseID);
                }
            }
        }

        private string warehouseName;
        [DataMember]
        [Required(AllowEmptyStrings = false, ErrorMessage = "Tên nhà kho không được bỏ trống.")]
        [StringLength(50, ErrorMessage = "Tên nhà kho không được dài quá 50 kí tự")]
        public string WarehouseName
        {
            get { return warehouseName; }
            set
            {
                if(!ReferenceEquals(warehouseName,value))
                {
                    warehouseName = value;
                    RaisePropertyChanged(() => WarehouseName);
                }
            }
        }

        private Employee manager;
        [DataMember]
        [Required(AllowEmptyStrings = false, ErrorMessage = "Quản lý nhà kho không được bỏ trống.")]
        public Employee Manager
        {
            get { return manager; }
            set
            {
                if (!ReferenceEquals(manager, value))
                {
                    manager = value;
                    RaisePropertyChanged(() => Manager);
                }
            }
        }

        private string address;
        [DataMember]
        [Required(AllowEmptyStrings = false, ErrorMessage = "Địa chỉ nhà kho không được bỏ trống.")]
        [StringLength(500, ErrorMessage = "Địa chỉ nhà kho không được dài quá 500 kí tự")]
        public string Address
        {
            get { return address; }
            set
            {
                if(!ReferenceEquals(address,value))
                {
                    address = value;
                    RaisePropertyChanged(() => Address);
                }
            }
        }

        private string officePhone;
        [DataMember]
        [Required(AllowEmptyStrings = false, ErrorMessage = "SDT nhà kho không được bỏ trống.")]
        [StringLength(15, ErrorMessage = "SDT nhà kho không được dài quá 15 kí tự")]
        public string OfficePhone
        {
            get { return officePhone; }
            set
            {
                if(!ReferenceEquals(officePhone,value))
                {
                    officePhone = value;
                    RaisePropertyChanged(() => OfficePhone);
                }
            }
        }

        private string description;
        [DataMember]
        public string Description
        {
            get { return description; }
            set
            {
                if(!ReferenceEquals(description,value))
                {
                    description = value;
                    RaisePropertyChanged(() => Description);
                }
            }
        }

        private ObservableCollection<Product> productCollection;
        [DataMember]
        public ObservableCollection<Product> ProductCollection
        {
            get { return productCollection; }
            set
            {
                if(!ReferenceEquals(productCollection,value))
                {
                    productCollection = value;
                    RaisePropertyChanged(() => ProductCollection);
                }
            }
        }

        private ObservableCollection<Material> materialCollection;
        [DataMember]
        public ObservableCollection<Material> MaterialCollection
        {
            get { return materialCollection; }
            set
            {
                if(!ReferenceEquals(materialCollection,value))
                {
                    materialCollection = value;
                    RaisePropertyChanged(() => MaterialCollection);
                }
            }
        }

        private bool isDelete;
        [DataMember]
        public bool IsDelete
        {
            get { return isDelete; }
            set
            {
                if (!Equals(isDelete, value))
                {
                    isDelete = value;
                    RaisePropertyChanged(() => IsDelete);
                }
            }
        }
    }
}